package cn.jobstart.service.impl;

import cn.jobstart.vo.ResumeWorkExperienceMiniDomainVO;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import cn.jobstart.modelExt.ResumeWorkExperienceExt;
import cn.jobstart.dao.IResumeWorkExperienceDao;
import cn.jobstart.searchExt.ResumeWorkExperienceSearchExt;
import cn.jobstart.pubInter.IBaseDao;
import cn.jobstart.pubInter.AbstractBaseService;
import cn.jobstart.service.IResumeWorkExperienceService;
import lombok.extern.slf4j.Slf4j;
import cn.jobstart.common.StringUtil;
import cn.jobstart.common.SkList;
import cn.jobstart.pubInter.exception.SkException;

import java.util.List;


/**
*    @author sunke
*    @Date 2023-09-06 15:00:21
*    @description ResumeWorkExperienceService      工作经历
*/
@Service(value = "resumeWorkExperienceService")
@Slf4j
public class ResumeWorkExperienceServiceImpl extends AbstractBaseService<ResumeWorkExperienceExt, ResumeWorkExperienceSearchExt,String> implements IResumeWorkExperienceService {

    @Resource(name = "resumeWorkExperienceDao")
    private IResumeWorkExperienceDao resumeWorkExperienceDao;

    @Override
    public IBaseDao<ResumeWorkExperienceExt, ResumeWorkExperienceSearchExt,String> getDao() {
        return resumeWorkExperienceDao;
    }

    /**
     * 工作经历
     *
     * @param resumeId
     * @return
     */
    @Override
    public String getWorkExperienceStrByResumeId(String resumeId) {
        try {
            List<ResumeWorkExperienceExt> list = getListByResumeId(resumeId);

            return StringUtil.getJsonArrayStrByList(list, ResumeWorkExperienceMiniDomainVO.class);


        } catch (Exception e) {

        }
        return "";
    }

    /**
     * 根据简历ID
     *
     * @param resumeId
     * @return
     */
    @Override
    public List<ResumeWorkExperienceExt> getListByResumeId(String resumeId) {
        if(StringUtil.isNullOrEmpty(resumeId)){
            return null;
        }
        try {
            return getAllList(ResumeWorkExperienceSearchExt.getInstance().setResumesIdEq(resumeId));
        } catch (SkException e) {
            return null;
        }
    }
}